package com.example.Servlet;

import com.alibaba.fastjson.JSON;
import com.example.Function.DataBaseOp;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
/**
 * @author echo
 * 删除错题
 */
@WebServlet("/DeleteErrorQuestion")
public class DeleteErrorQuestion extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        String email = req.getParameter("email");
        String code = req.getParameter("code");
        String data = req.getParameter("data");
        List<String> strings = JSON.parseArray(data, String.class);
        DataBaseOp.deleteErrorQuestion(strings,DataBaseOp.getErrorCode(code),email);
        PrintWriter out = resp.getWriter();
        out.println(new Gson().toJson(true));
    }
}
